Log in Register Dashboard Temp Share Shortlinks Frames API

HTMLify

app.js
Views: 6 | Author: cody
const nav = document.querySelector(".nav");

window.addEventListener("scroll", fixNav);

function fixNav() {
  if (window.scrollY > nav.offsetHeight + 150) {
    nav.classList.add("active");
  } else {
    nav.classList.remove("active");
  }
}

Comments